<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			//创建promise对象
			let promise=new Promise((resolve, reject)=>{
				let num=Math.random()*10;
				if(num>0){
					resolve(num);
				}
				else{
					reject(num);
				}
			})
			
			//
			function test(){
				//then为promise中的函数
				promise.then((num)=>{
					console.log("then:"+num);
				})
				.catch((num)=>{
					console.log("catch:"+num);
				})
			}
		</script>
	</head>
	<body>
		<input type="button" onclick="test()" value="测试" />
	</body>
</html>
